<template>
  <el-dialog
      :visible.sync="successVisible"
      :modal="false"
      :close-on-click-modal="false"
      :before-close="handleSuccessClose">
    <div class="content">
      <img src="../assets/images/succeed.png" alt="">
      <p>{{successMsg}}</p>
      <div class="pay-btn">
        <el-button @click="handleSuccessClose">back</el-button>
      </div>
    </div>
  </el-dialog>
</template>

<script>

import {getAllCoupons} from "../api/shopMall";
import {mapState} from "vuex";

export default {
  name: "success",
  props:{
    successVisible:{
      type:Boolean,
      defaulted:false
    }
  },
  computed: {
    ...mapState({comData:state => state.comData.comData,successMsg:state => state.success.successMsg})
  },
  methods:{
    handleSuccessClose(){
      let data = this.comData
      getAllCoupons(data).then(res => {
        this.$store.dispatch('coupons/getCouponList', res.data)
      })
      this.$store.dispatch('success/changeSuccess')
    },
  }
}
</script>

<style scoped lang="scss">
::v-deep .el-dialog{
  width: 490px;
  height: 390px;
  background: rgba(0, 0, 0, 0.9);
  border-radius: 38px;
}
  .content{
    text-align: center;
    img{
      width: 150px;
      height: 150px;
    }
    p{
      font-size: 21px;
      color: #ffffff;
      padding: 6px 0 37px;
    }
    button{
      width: 252px;
      height: 67px;
      background: linear-gradient(257deg, #841FC3 0%, #FC3C02 100%);
      border-radius: 33px;
      border: none;
      color: #ffffff;
    }
  }
</style>